<?php
/**
 * ClassName: performance_log
 * Description: 医生治疗服务绩效记录
 * @Author 周昌
 * @Create 2024/1/18 10:17
 */

namespace app;


use epii\server\Args;
use service\admin\PerformanceLogService;
use service\admin\HospitalService;
use service\admin\RoleService;

class performance_log extends base
{
    public function init()
    {
        parent::init();
        $this->accessDenied();
    }
    public function index()
    {
        if($this->adminInfo['role']==1){
            $this->assign('hospitals',HospitalService::getSelect());
        }
        $this->adminUiDisplay();
    }

    public function ajax_data()
    {
        $map = [];
        //登录用户权限判断
        $hospital_id=$this->adminInfo['hospital_id'];
        if($hospital_id){
            $map[]=['a.hospital_id','=',$hospital_id];
        }
        $name=Args::params('name');
        if($name){
            $map[]=['a.group_name','like','%'.$name.'%'];
        }
        //时间筛选
        $start_time=Args::params('start_time');
        if($start_time){
            $start_time=strtotime($start_time);
            $map[]=['p.addtime','>=',$start_time];
        }
        $end_time=Args::params('end_time');
        if($end_time){
            $end_time=strtotime($end_time);
            $map[]=['p.addtime','<=',$end_time];
        }
        //限制医生角色
        $map[]=['a.role','=',RoleService::$role['doctor']['id']];
        echo PerformanceLogService::getAjaxData($map);
    }
    //绩效明细
    public function info()
    {
        $admin_id=Args::params('admin_id/d');
        $this->_as_admin_id=$admin_id;
        $this->adminUiDisplay();
    }
    //绩效明细数据
    public function info_ajax_data(){
        $map = [];
        //某医生绩效明细
        $admin_id=Args::params('admin_id/d');
        if($admin_id){
            $map[]=['admin_id','=',$admin_id];
        }
        //时间筛选
        $start_time=Args::params('start_time');
        if($start_time){
            $start_time=strtotime($start_time);
            $map[]=['addtime','>=',$start_time];
        }
        $end_time=Args::params('end_time');
        if($end_time){
            $end_time=strtotime($end_time);
            $map[]=['addtime','<=',$end_time];
        }
        echo PerformanceLogService::getInfoData($map);
    }

}